<!DOCTYPE html>
<html lang="cmn-Hans" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>设置我的资料</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" th:href="@{/frame/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/customer_admin.css}" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">设置我的资料</div>
                <div class="layui-card-body" pad15>
                    <div class="layui-form" lay-filter="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">我的角色</label>
                            <div class="layui-input-inline">
                                <select name="role" lay-verify="">
                                    <option value="超级管理员" th:selected="${session.current_administrator.role} eq '超级管理员'" th:disabled="${session.current_administrator.role} ne '超级管理员'" th:text="超级管理员"></option>
                                    <option value="普通管理员" th:selected="${session.current_administrator.role} eq '普通管理员'" th:disabled="${session.current_administrator.role} ne '普通管理员'" th:text="普通管理员"></option>
                                    <option value="审核管理员" th:selected="${session.current_administrator.role} eq '审核管理员'" th:disabled="${session.current_administrator.role} ne '审核管理员'" th:text="审核管理员"></option>
                                    <option value="编辑管理员" th:selected="${session.current_administrator.role} eq '编辑管理员'" th:disabled="${session.current_administrator.role} ne '编辑管理员'" th:text="编辑管理员"></option>
                                </select>
                            </div>
                            <div class="layui-form-mid layui-word-aux">当前角色不可更改为其它角色</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">工号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="adminid" th:value="${session.current_administrator.adminid}" readonly
                                       class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">不可修改。一般用于后台登入名</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">昵称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="nickname" th:value="${session.current_administrator.nickname}"
                                       lay-verify="nickname" autocomplete="off"
                                       placeholder="请输入昵称" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">性别</label>
                            <div class="layui-input-block">
                                <input type="radio" name="gender" value="男" title="男" th:checked="${session.current_administrator.gender} eq '男'"/>
                                <input type="radio" name="gender" value="女" title="女" th:checked="${session.current_administrator.gender} eq '女'"/>
                                <input type="radio" name="gender" value="保密" title="保密" th:checked="${session.current_administrator.gender} eq '保密'"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">头像</label>
                            <div class="layui-input-inline">
                                <input lay-verify="required" id="LAY_avatarSrc" placeholder="图片地址" type="hidden"
                                       th:value="@{'/picture/getAvatar?fileName='+${session.current_administrator.avatar}}">
                            </div>
                            <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <button type="button" class="layui-btn layui-btn-primary" id="myUploadAvatar">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                                <button class="layui-btn layui-btn-primary" layadmin-event="avartatPreview">查看图片
                                </button>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">手机</label>
                            <div class="layui-input-inline">
                                <input type="text" name="phone" th:value="${session.current_administrator.phone}" lay-verify="phone" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">邮箱</label>
                            <div class="layui-input-inline">
                                <input type="text" name="email" th:value="${session.current_administrator.email}" lay-verify="email" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">个性签名</label>
                            <div class="layui-input-block">
                                <textarea name="signature" placeholder="请输入内容" class="layui-textarea" th:utext="${session.current_administrator.signature}"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="setmyinfo">确认修改</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重新填写</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script th:src="@{/frame/layui/layui.js}"></script>
<script>
    layui.config({
        base: '/frame/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set', 'form','upload'], function () {
        var form = layui.form;
        var admin = layui.admin;
        form.on("submit(setmyinfo)", function (t) {
            admin.req({
                url: '[[@{/admin/setInfo}]]'
                , type: 'post'
                , data: t.field
                , done: function (res) {
                    if (res.issuccess) {
                        layer.msg('更新成功！', {
                            //offset: '15px'
                            icon: 1
                            , time: 2000
                        });
                    } else {
                        layer.msg('更新失败，请检查输入是否有误！', {
                            //offset: '15px'
                            icon: 2
                            , time: 2000
                        });
                    }
                }
            });
        });


        var upload=layui.upload;
        upload.render({
            elem:'#myUploadAvatar'
            ,url:'[[@{/admin/uploadAvatar}]]'
            ,done:function (res) {
                document.querySelector('#LAY_avatarSrc').value=res.msg;
                layer.msg('上传成功!',{
                    icon:1
                    ,time:2000
                });
            }
            ,error:function () {
                layer.msg('上传失败!',{
                    icon:2
                    ,time:2000
                });
            }
        });
    });
</script>
</body>
</html>